//$URL: http://dasding.googlecode.com/svn/branches/testzeugs/data/data/src/main/java/de/piratech/dasding/data/AbstractAction.java $
//$Id: AbstractAction.java 89 2012-11-12 14:55:42Z amuthmann@gmail.com $
/*
 * Copyright 2012 Piratech.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.piratech.dasding.data;

import de.piratech.dasding.data.database.DataType;
import java.util.Date;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 * An Abstract action used as base for actions and events
 *
 * @author deveth0
 */
public class AbstractAction extends AbstractDataObject {

  private String mContact;
  private String mName;
  private String mDescription;
  private String mFinalWords;
  private String mFurtherInformation;
  private Location mLocation;
  private String mResponsible;
  private Date mTime;

  public String getName() {
    return mName;
  }

  public void setName(String pName) {
    this.mName = pName;
  }

  public String getContact() {
    return mContact;
  }

  public void setContact(String pUserId) {
    this.mContact = pUserId;
  }

  @JsonIgnore
  public void setContact(User pContact) {
    this.mContact = pContact != null ? pContact.getId() : null;
  }

  public String getDescription() {
    return mDescription;
  }

  public void setDescription(String pDescription) {
    this.mDescription = pDescription;
  }

  public String getFinalWords() {
    return mFinalWords;
  }

  public void setFinalWords(String pFinalWords) {
    this.mFinalWords = pFinalWords;
  }

  public String getFurtherInformation() {
    return mFurtherInformation;
  }

  public void setFurtherInformation(String pFurtherInformation) {
    this.mFurtherInformation = pFurtherInformation;
  }

  public Location getLocation() {
    return mLocation;
  }

  public void setLocation(Location pLocation) {
    this.mLocation = pLocation;
  }

  public String getResponsible() {
    return mResponsible;
  }

  public void setResponsible(String pUserId) {
    this.mResponsible = pUserId;
  }

  @JsonIgnore
  public void setResponsible(User pResponsible) {
    this.mResponsible = pResponsible != null ? pResponsible.getId() : null;
  }

  public Date getTime() {
    return mTime;
  }

  public void setTime(Date pTime) {
    this.mTime = pTime;
  }

  @Override
  @JsonIgnore
  public boolean isValid() {
    return StringUtils.isNotBlank(mName)
            && StringUtils.isNotBlank(mDescription)
            && StringUtils.isNotBlank(mContact)
            && mTime != null
            && mLocation != null;
  }

  @Override
  public DataType getDataType() {
    return null;
  }
}
